CC=g++
CFLAGS=-Wall -std=c++0x

DIR=Email
BIN=Bin
OBJ=Obj
LIBS=Obj/config.o Obj/log.o Obj/authr.o Obj/nsr.o Obj/utf8.o Obj/us-client*.o Obj/ns-client*.o Obj/an-client*.o Obj/ar-client*.o
CSOURCE=$(DIR)/email.cpp $(DIR)/em.rpc_clnt.c $(DIR)/em.rpc_xdr.c
SSOURCE=$(DIR)/emailsrv.cpp $(DIR)/em.rpc_svc.c $(DIR)/em.rpc_xdr.c $(DIR)/em.server.cpp
HEADERS=$(DIR)/em.rpc.h

all:client server test

client: $(CSOURCE) $(HEADERS) $(DIR)/email.h
	$(CC) $(CFLAGS) -c -o $(OBJ)/em-client-xdr.o $(DIR)/em.rpc_xdr.c
	$(CC) $(CFLAGS) -c -o $(OBJ)/em-client-rpc.o $(DIR)/em.rpc_clnt.c
	$(CC) $(CFLAGS) -c -o $(OBJ)/em-client.o $(DIR)/email.cpp

server: $(SSOURCE) $(HEADERS) $(DIR)/emailsrv.h
	$(CC) $(CFLAGS) $(LIBS) -o $(BIN)/em-server $(SSOURCE)

test:
	$(CC) $(CFLAGS) -o $(BIN)/em-test $(LIBS) $(OBJ)/em-client*.o $(DIR)/test.cpp
